﻿package com.bn.NNYY;

/*
 * 控制背景图片变换的线程
 */

public class BackgroundPicThread extends Thread {
	
	GameView gameview;
	private boolean Flag=false;//线程标志位
	private int sleepSpan=500;//线程休息的时间
	
	public BackgroundPicThread(GameView gameview)//构造方法
	{
		this.gameview=gameview;
	}
	@Override
	public void run()
	{
		while(isFlag())
		{
			try
			{
				if(gameview.backgroundpic.i==2)
				{
					gameview.backgroundpic.i=0;
				}else
				{
					gameview.backgroundpic.i++;
				}
				sleep(sleepSpan);//休息50毫秒
			}catch(Exception e)
			{
				e.printStackTrace();
			}
		}		
	}
	
	public void setFlag(boolean Flag) {
		this.Flag = Flag;
	}
	public boolean isFlag() {
		return Flag;
	}
	
}
